<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex align-stretch benben-position-layout flex bindAlipay_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex align-center justify-between flex-sub bindAlipay_fd0_0'>
					<view class='flex align-center bindAlipay_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
						data-url="1">
						<text class='fu-iconfont2  bindAlipay_fd0_0_c0_c0'>&#xE794;</text>
					</view>
					<view class='flex align-center'>
						<text class='bindAlipay_fd0_0_c1_c0'>绑定微信</text>
					</view>
					<view class='flex align-center bindAlipay_fd0_0_c0'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---绑定支付宝flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout bindAlipay_flex_1">
				<view class='flex flex-direction align-stretch bindAlipay_fd1_0'>
					<view class='flex flex-wrap align-center bindAlipay_fd1_0_c0'>
						<text class='bindAlipay_fd1_0_c0_c0'>第一步：先获取手机验证码</text>
					</view>
					<view class='flex flex-wrap align-center bindAlipay_fd1_0_c1'>
						<text class='bindAlipay_fd1_0_c1_c0'>绑定的用户手机</text>
						<text class='bindAlipay_fd1_0_c1_c0'>{{dataMessage.mobile_hide}}</text>
					</view>
					<view class='flex flex-wrap align-center bindAlipay_fd1_0_c2'>
						<text class='bindAlipay_fd1_0_c2_c0'>验证码</text>
						<input class='flex-sub bindAlipay_fd1_0_c2_c1' type="number" :placeholder="`请输入验证码`"
							confirm-type="done" :maxlength="6" placeholder-style="color:#BFBFBF;font-size:28rpx"
							v-model="code" />
						<benben-send-verification-code ref="vCode1689818850301" class=' bindAlipay_fd1_0_c2_c2'
							after-text='后重新获取' before-text='获取验证码' type='7'
							:phone="dataMessage.mobile"></benben-send-verification-code>
					</view>
					<view class='flex flex-wrap align-center bindAlipay_fd1_0_c3'>
						<text class='bindAlipay_fd1_0_c0_c0'>第二步：上传微信收款二维码</text>
					</view>
					<view class='flex flex-direction flex-wrap align-start bindAlipay_fd1_0_c4'>
						<view class='flex flex-wrap align-center'>
							<view class="upload position-relative bindAlipay_fd1_0_c4_c0_c0">
								<text v-if="dataBangding.qrcode != ''" @tap="dataBangding.qrcode = ''"
									class='fu-iconfont2 position-absolute bindAlipay_fd1_0_c4_c0_c0_icon'>&#xE8E7;</text>
								<image class=" bindAlipay_fd1_0_c4_c0_c0" mode="aspectFill"
									@tap="soloChooseImage('qrcode','qrcode',dataBangding,dataBangding)"
									:src="dataBangding.qrcode ? dataBangding.qrcode : STATIC_URL+'113.png'">
								</image>
							</view>
						</view>
						<text class='bindAlipay_fd1_0_c4_c1'>上传二维码</text>
					</view>
					<view class='flex flex-wrap align-center bindAlipay_fd1_0_c1'>
						<text class='bindAlipay_fd1_0_c0_c0'>第三步：填写微信真实姓名</text>
					</view>
					<view class='flex flex-wrap align-center bindAlipay_fd1_0_c6'>
						<text class='bindAlipay_fd1_0_c6_c0'>真实姓名</text>
						<input class='flex-sub bindAlipay_fd1_0_c2_c1' type="text" :placeholder="`请输入真实姓名`"
							confirm-type="done" :maxlength="-1" placeholder-style="color:#BFBFBF;font-size:28rpx"
							v-model="dataBangding.true_name" />
					</view>
				</view>
			</view>

			<!---绑定支付宝flex布局结束-->
			<view class='flex flex-wrap align-center justify-center bindAlipay_fd1_1'>
				<button class='bindAlipay_fd1_1_c0' @tap.stop="queryListFunc()">提交</button>
			</view>

		</view>
	</view>
</template>
<script>
	import UploadImage from '@/common/utils/upload-image.js'
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},


		data() {
			return {
				"qrcode_url": "",
				"real_name": "",
				"dataMessage": {
					"invite_code": "",
					"address": "",
					"address_code": "",
					"hobby": "",
					"tags": "",
					"id": "",
					"userlevel_id": "",
					"mobile": "",
					"real_name": "",
					"avatar": "",
					"account": "",
					"email": "",
					"birthday": "",
					"gender": "",
					"create_time": "",
					"user_money": "",
					"freeze_money": "",
					"total_consumption_money": "",
					"score": "",
					"_mobile": "",
					"coupon": "",
					"collection_count": "",
					"browse_count": "",
					"total_money": "",
					"certified": "",
					"nickname": "",
					"is_pay_password": "",
					"follow_count": ""
				},
				"dataBangding": {
					"aid": "",
					"is_default": "",
					"create_time": "",
					"update_time": "",
					"status": "",
					"true_name": "",
					"account": "",
					"qrcode": "",
					"bank_name": "",
					"bank_address": "",
					"remark": ""
				},
				"code": "",
				"type": "0",  // 0未绑定  1已绑定
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			let {
				type
			} = options
			if (type !== undefined) this.type = type
			this.getUserinfoFunc()
			this.getbangdingFunc()
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//上传单图、多图方法
			soloChooseImage(id, path, obj, obj1, fnName = false) {
				let self = this
				if (!obj) obj = this
				if (!obj1) obj1 = this
				if (self.uploading) {
					return
				}
				if (global.platform == 'ios') {
					// 从相册中选择图片
					uni.chooseImage({
						count: 1, // 默认3
						sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
						success: function(res) {
							self.uploading = true
							// 开始上传
							new UploadImage(res.tempFiles, {
								complete: function(res) {
									self.uploading = false
									if (id) self.$set(obj, id, res[0].id)
									if (path) self.$set(obj1, path, res[0].path)
									if (fnName) self[fnName]()
								},
							})
						},
					})
				} else {
					uni.showModal({
						title: '提示',
						content: '访问您的相机或相册权限，以及存储权限，使用拍照或修改图片等功能，用于上传图片，是否允许？',
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
								
								// 从相册中选择图片
								uni.chooseImage({
									count: 1, // 默认3
									sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
									success: function(res) {
										self.uploading = true
										// 开始上传
										new UploadImage(res.tempFiles, {
											complete: function(res) {
												self.uploading = false
												if (id) self.$set(obj, id, res[0].id)
												if (path) self.$set(obj1, path, res[0].path)
												if (fnName) self[fnName]()
											},
										})
									},
								})
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						},
						fail: function(err) {
							console.log(err);
						}
					})
				}
				
			},
			//钱包-设置提现账户
			async queryListFunc() {
				if (!validate(this.code, 'require')) {
					this.$message.info('请输入验证码');
					return false;
				}
				if (!validate(this.code, 'captcha')) {
					this.$message.info('请输入正确的验证码');
					return false;
				}
				if (!validate(this.dataBangding.qrcode, 'require')) {
					this.$message.info('请上传二维码');
					return false;
				}
				if (!validate(this.dataBangding.true_name, 'require')) {
					this.$message.info('请输入真实姓名');
					return false;
				}
				//请求方法
				//数据验证

				let data5f6db4db8abcf = await this.$api.post(global.apiUrls.post6600d5dac33b3, {
					account_type: 1,
					true_name: this.dataBangding.true_name,
					qrcode: this.dataBangding.qrcode,
					mobile: this.dataMessage.mobile,
					code: this.code,
					type: '7'
				});

				if (data5f6db4db8abcf.data.code != 1) {
					this.$message.info(data5f6db4db8abcf.data.msg);
					return
				}

				this.$message.info('支付宝绑定成功');
				setTimeout(() => {
					this.$urouter.navigateBack(1);
				}, 800)
			},
			//获取绑定信息
			async getbangdingFunc() {
				let datadataBangding = await this.$api.post(global.apiUrls.post66028d91ed8ce, {
					account_type: 1
				});
				
				if (datadataBangding.data.code != 1) {
					this.$message.info(datadataBangding.data.msg);
					return
				}
				let infodataBangding = datadataBangding.data;
				this.dataBangding = infodataBangding.data
			},
			//获取会员详细信息
			async getUserinfoFunc() {
				//请求方法
				//数据验证

				let datadataMessage = await this.$api.post(global.apiUrls.post64366f0e3b620, {

				});

				if (datadataMessage.data.code != 1) {
					this.$message.info(datadataMessage.data.msg);
					return
				}
				let infodataMessage = datadataMessage.data;
				this.dataMessage = infodataMessage.data

			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto;
	}

	.bindAlipay_flex_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.bindAlipay_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333;
	}

	.bindAlipay_fd0_0_c0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #333;
	}

	.bindAlipay_fd0_0_c0 {
		width: 180rpx;
	}

	.bindAlipay_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
	}

	.bindAlipay_flex_1 {
		background: #fff;
		padding: 0rpx 0rpx 0rpx 0rpx;
	}

	.bindAlipay_fd1_1_c0 {
		background: #3083FF;
		font-size: 32rpx;
		color: #fff;
		width: 686rpx;
		height: 80rpx;
		line-height: 80rpx;
		font-weight: 700;
		border-radius: 50rpx;
	}

	.bindAlipay_fd1_1 {
		width: 750rpx;
		position: fixed;
		left: 0rpx;
		bottom: calc(40rpx + var(--window-bottom));
	}

	.bindAlipay_fd1_0_c6_c0 {
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(102, 102, 102, 1);
		margin: 0rpx 32rpx 0rpx 0rpx;
	}

	.bindAlipay_fd1_0_c6 {
		padding: 0rpx 0rpx 32rpx 0rpx;
		line-height: 48rpx;
	}

	.bindAlipay_fd1_0_c4_c1 {
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(102, 102, 102, 1);
		margin: 24rpx 0rpx 0rpx 0rpx;
	}

	.bindAlipay_fd1_0_c4_c0_c0_icon {
		top: 0rpx;
		right: 0rpx;
		z-index: 9;
		color: #ff5536;
	}

	.bindAlipay_fd1_0_c4_c0_c0 {
		width: 160rpx;
		height: 160rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	.bindAlipay_fd1_0_c4 {
		border-bottom: 1px solid #eee;
		padding: 0rpx 0rpx 32rpx 0rpx;
		margin: 0rpx 0rpx 40rpx 0rpx;
	}

	.bindAlipay_fd1_0_c3 {
		margin: 40rpx 0rpx 32rpx 0rpx;
	}

	.bindAlipay_fd1_0_c2_c2 {
		text-align: center;
		font-size: 28rpx;
		color: rgba(48, 144, 255, 1);
		font-weight: 400;
	}

	.bindAlipay_fd1_0_c2_c1 {
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(51, 51, 51, 1);
	}

	.bindAlipay_fd1_0_c2_c0 {
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(102, 102, 102, 1);
		margin: 0rpx 24rpx 0rpx 0rpx;
	}

	.bindAlipay_fd1_0_c2 {
		border-bottom: 1px solid #eee;
		padding: 0rpx 0rpx 32rpx 0rpx;
	}

	.bindAlipay_fd1_0_c1_c0 {
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(102, 102, 102, 1);
	}

	.bindAlipay_fd1_0_c1 {
		margin: 0rpx 0rpx 32rpx 0rpx;
	}

	.bindAlipay_fd1_0_c0_c0 {
		font-size: 28rpx;
		font-weight: 500;
		color: rgba(51, 51, 51, 1);
	}

	.bindAlipay_fd1_0_c0 {
		padding: 40rpx 0rpx 32rpx 0rpx;
	}

	.bindAlipay_fd1_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
	}
</style>